﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AiLuWeb.WebSite.Code;
using AiLuWeb.Business;
using AiLuWeb.Model;
using System.Configuration;
using System.Collections;

namespace AiLuWeb.WebSite.WebAdmin
{
    public partial class left : AuthPageBase
    {
        Hashtable table = new Hashtable();
        protected IList<SysModule> sysModules = new List<SysModule>();
        ISysModuleBusiness smBll = new SysModuleBusinessFactory().CreateSysModuleBusiness();
        IUAdministratorBusiness uaBll = new UAdministratorBusinessFactory().CreateUAdministratorBusiness();

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            table.Add(SysModuleHash.OrderField, "sort");
            table.Add(SysModuleHash.OrderDirection, "asc");

            if (HttpContext.Current.User.Identity.Name != "" && HttpContext.Current.User.Identity.Name != ConfigurationManager.AppSettings["SuperuserName"])
            {
                UAdministrator userInfo = uaBll.GetByName(User.Identity.Name);
                if (userInfo != null)
                {
                    string[] mids = userInfo.ModuleIds.Split(',');
                    string strids = "";
                    for (int i = 0; i < mids.Length; i++)
                    {
                        if (i == mids.Length - 1)
                        {
                            strids += "'" + mids[i] + "'";
                        }
                        else
                        {
                            strids += "'" + mids[i] + "',";
                        }
                    }
                    if (!string.IsNullOrEmpty(strids))
                    {
                        table.Add(SysModuleHash.Id, strids);
                        sysModules = smBll.GetAllSysModule(table);
                    }
                }
            }
            else
            {
                sysModules = smBll.GetAllSysModule(table);
            }

            sysModules = smBll.GetAllSysModule(table);
        }
    }
}